home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr46 / be310.zip / HOME&END.CHS < prev    next >
Text File  |  1993-06-01  |  2KB  |  61 lines

  1. /* CHESS FUNCTION(S): go_home, go_end
  2. /*              DATE: 2/1/93
  3. /*            AUTHOR: C. Schanck
  4. /*
  5. /*       DESCRIPTION:
  6. /* This is a pair of functions which can be attached to your home
  7. /* and end keys and will give you some different functionality.
  8. /* 
  9. /* for the first, pressing the home key will take you to the:
  10. /*    1) beginning of the line, if you are not there
  11. /*    2) top of the screen if you are not there
  12. /*    3) top of the file if you are not there
  13. /* evaluated in that order.
  14. /* 
  15. /* for the second, pressing the end key will take you to the:
  16. /*    1) end of the line, if you are not there
  17. /*    2) bottom of the screen if you are not there
  18. /*    3) bottom of the file if you are not there
  19. /* evaluated in that order.
  20. /*
  21. /* many thanks to the CIS gang for there suggestions and efforts in
  22. /* these -- they aren't my originals, just mods of things people on
  23. /* Compuserve came up with!  Enjoy!
  24. /*
  25. go_home{
  26.    int i,ret;
  27.    i=ask("file_column")       /* find out what column we are on...
  28.    if(i==1){                  /* were we at the beginning?
  29.       if(ask("file_y")==1){   /* are we at the top of the screen?
  30.          ret=b_cmd("top_of_file");
  31.       }   
  32.       else{
  33.          /* here we were at the begin of the line, but not the screen
  34.          ret=b_cmd("top_of_screen");
  35.       }
  36.    }   
  37.    else
  38.       ret=b_cmd("begin_line");
  39.    /* return the value of whatever bingo op we did last...
  40.    return(ret);                                                           
  41. }
  42. go_end{
  43.    int i,ret;
  44.    i=ask("file_column")       /* find out what column we are on...
  45.    ret=b_cmd("end_line");     /* go to the end of the line
  46.    if(i==ask("file_column")){ /* were we at the end?
  47.       /* calculate the cursor position which is the end ... 
  48.       i=ask("file_w_top")+ask("file_w_height")-1;
  49.       if(ask("file_y")==i){   /* are we there?
  50.          /* we are at the bottom of the screen
  51.          ret=b_cmd("bot_of_file");
  52.       }   
  53.       else{
  54.          /* here we were at the end of the line, but not the bot of screen
  55.          ret=b_cmd("bottom_of_screen");
  56.       }
  57.    }
  58.    /* return the value of whatever bingo op we did last...
  59.    return(ret);                                                           
  60.